package com.ushio.gougouwangguo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ushio.gougouwangguo.entity.mysql.OccupationType;
import com.ushio.gougouwangguo.entity.vo.OccupationTypeListVo;
import com.ushio.gougouwangguo.mapper.OccupationTypeMapper;
import com.ushio.gougouwangguo.service.OccupationTypeService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class OccupationTypeServiceImpl extends ServiceImpl<OccupationTypeMapper, OccupationType> implements OccupationTypeService {

    @Autowired
    OccupationTypeMapper occupationTypeMapper;

    @Override
    public List<OccupationTypeListVo> getOccupationTypeListVo() {
        return occupationTypeMapper.selectList(new LambdaQueryWrapper<>()).stream().map(occupationType -> {
            OccupationTypeListVo occupationTypeListVo = OccupationTypeListVo.builder().build();
            BeanUtils.copyProperties(occupationType, occupationTypeListVo);
            return occupationTypeListVo;
        }).collect(Collectors.toList());
    }
}
